package com.smsc.headend.connector.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smsc.headend.module.request.entity.HdComTraffic;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface HdComTrafficMapper extends BaseMapper<HdComTraffic> {

    @Select("select SEQ from HD_COM_TRAFFIC WHERE COM_ID= #{comId} AND YEAR_DATE=#{yearDate} AND COM_TYPE = #{comType}")
    @ResultType(Long.class)
    public Long getComTrafficSeq(@Param("comId") Long comId, @Param("yearDate") String yearDate, @Param("comType") String comType);


    @Update("UPDATE HD_COM_TRAFFIC SET INBOUND_SUM = INBOUND_SUM + #{inboundSum}, OUTBOUND_SUM = OUTBOUND_SUM + #{outboundSum},  PACKET_SIZE = PACKET_SIZE  + #{packetSize}, " +
            " COM_TYPE = #{comType} " +
            " WHERE SEQ = #{seq}")
    public void updateComTraffic(HdComTraffic hdComTraffic);
}
